<?

// v 0.47

// camel Case - variable names beginning with _ are rejected
function _churro_camelCase( $str = '' ){
	$cc = preg_replace_callback( '/-(\w)/', '_churro_camelCaseCallback', $str);
	if( strpos($cc, '_') === 0 ){ 
		return FALSE;
	}
	return $cc;
}

function _churro_camelCaseCallback( $matches ){
     return ucfirst( $matches[1] );
}

// set a flash message if $message is set
// get and erase a flash message if only $key is set
function flash( $key = null, $message = null ){

	if( !isset($_SESSION['flash']) || !is_array($_SESSION['flash']) ){
		$_SESSION['flash'] = array();
	}
	
	if( is_null($message) ){
		// getting the messsage
		if( isset($_SESSION['flash'][$key]) ){
			$message = $_SESSION['flash'][$key];
			unset( $_SESSION['flash'][$key] );
			return $message;
		} else {
			return FALSE;
		}
	} else {
		// setting the message
		$_SESSION['flash'][$key] = $message;
	}
}

// shortcut for (object) array();
function object( array $a = null ){
	return (object) $a;
}

// strip slashes recursively
function strip( &$x = null ){
	if( is_array($x) || is_object($x) ){
		foreach( $x as $k=>&$v ){
			$v = strip( $v );
		}
	} else {
		$x = stripslashes( $x );
	}
	return $x;
}

// end of file
// functions_Churro.php